﻿
@using Kooboo.CMS.Content.Models;
@using Kooboo.CMS.Content.Query;
@{ var schema = (Kooboo.CMS.Content.Models.Schema)ViewData["Schema"];
    var allowedEdit = (bool)ViewData["AllowedEdit"];
    var allowedView = (bool)ViewData["AllowedView"];
    var parentUUID = ViewContext.RequestContext.AllRouteValues()["parentUUID"];
    var parentFolder=ViewContext.RequestContext.AllRouteValues()["Folder"];
}
@using(Html.BeginForm(ViewContext.RequestContext.AllRouteValues()["action"].ToString()
    , ViewContext.RequestContext.AllRouteValues()["controller"].ToString()
    , ViewContext.RequestContext.AllRouteValues()
    , FormMethod.Post
    , new RouteValueDictionary(new { enctype = "application/x-www-form-urlencoded" })))
{
    <div class="common-form">
    <fieldset>
    <table><tr>
            <td>
            <label for="Title">Title</label>
            </td>
            <td>
            <input id="Title" name="Title" type="text" value="@(Model.Title ?? "")" />
            @Html.ValidationMessageForColumn(((ISchema)ViewData["Schema"])["Title"], null)
            </td>          
            </tr><tr>
            <td>
            <label for="Body">Body</label>
            </td>
            <td>
            <textarea name="Body" rows="10" cols="100" >@(Model.Body ?? "")</textarea> 
            @Html.ValidationMessageForColumn(((ISchema)ViewData["Schema"])["Body"], null)
            </td>          
            </tr><tr>
            <td>
            <label for="Name">Name</label>
            </td>
            <td>
            <input id="Name" name="Name" type="text" value="@(Model.Name ?? "")" />
            @Html.ValidationMessageForColumn(((ISchema)ViewData["Schema"])["Name"], null)
            </td>          
            </tr>
            @if (allowedEdit) {
                <tr>
            <td>
            <label for="Published">Published</label>
            </td>
            <td>
            <input name="Published" type="checkbox" @(Convert.ToBoolean(Model.Published)?"checked":"") value="true"/>
                                    <input type="hidden" value="false" name="Published"/>
            @Html.ValidationMessageForColumn(((ISchema)ViewData["Schema"])["Published"], null)
            </td>          
            </tr>
            }
    @Html.Action("Categories", ViewContext.RequestContext.AllRouteValues())
    @if (schema.IsTreeStyle && parentUUID!=null)
    {
        <input type="hidden" name="ParentUUID" value="@parentUUID"/> 
        <input type="hidden" name="ParentFolder" value="@parentFolder" />
    }
    </table>
    </fieldset>
    <p class="buttons"><button type="submit">@("Save".Localize())</button> <a href="javascript:;" class="dialog-close button">@("Close".Localize())</a> </p>
    </div>
}